<template>
  <h1>{{ msg }}--{{ count }}</h1>
  <a-button type="primary" @click="changeCount">
    增加
  </a-button>
</template>

<script setup lang="ts">
import { onMounted, ref, nextTick } from 'vue';
// import { useStoreA } from '@/storeVuex/module/moduleA';
import { useStoreRoot } from '@/storeVuex';
defineProps<{
  msg: string;
}>();
const emits = defineEmits<{
  (e: 'change', id: number): void;
}>();

onMounted(() => {
  count.value = storeRoot.state.moduleB.count;
  emits('change', 123);
});
const count = ref(0);
// const storeA = useStoreA();
const storeRoot = useStoreRoot();
const changeCount = async () => {
  storeRoot.commit('moduleB/increment', 33);
  await nextTick();
  count.value = storeRoot.state.moduleB.count;
};
</script>
<style scoped></style>
